<chapter xml:id="set_of_chars.h">
<title><tt>__vic/set_of_chars.h</tt></title>

<chapter xml:id="set_of_chars">
<title><tt>set_of_chars</tt></title>

<code-block lang="C++"><![CDATA[
class set_of_chars
{
public:
    constexpr set_of_chars();
    template<class Iter> constexpr set_of_chars(Iter begin, Iter end);
    constexpr set_of_chars(std::initializer_list<char> set); // C++11
    constexpr set_of_chars(const char *c_str);

    constexpr bool contains(char ch) const;

    constexpr void add(char ch);
    constexpr void remove(char ch);

    template<class Iter> constexpr void add(Iter begin, Iter end);
    constexpr void add(const char *c_str);
    constexpr void add(std::initializer_list<char> set); // C++11

    template<class Iter> void assign(Iter begin, Iter end);
    void assign(const char *c_str)
    void assign(std::initializer_list<char> set); // C++11

    void clear();
};
]]></code-block>

<p>Compact (only 32 bytes) and very fast implemetation of a set of chars. The
cost of the <tt>contains()</tt> operation is always constant regardles of the
argument and number of elements in the set.</p>

<section><title>Class members</title>

<synopsis>
<prototype>constexpr set_of_chars()</prototype>
<p>Creates an empty set.</p>
<postcondition><tt>contains(char(ch)) == false</tt> for any char
</postcondition>
</synopsis>

<synopsis>
<prototype>template&lt;class Iter> constexpr set_of_chars(Iter begin, Iter end)</prototype>
<prototype>constexpr set_of_chars(std::initializer_list&lt;char> set) <badge>C++11</badge></prototype>
<p>Creates a set filled with characters from the specified range of values.</p>
<note><tt>constexpr</tt> since C++14 only!</note>
</synopsis>

<synopsis>
<prototype>constexpr set_of_chars(const char *c_str)</prototype>
<p>Creates a set filled with characters from the specified C-string excluding
NULL-terminator.</p>
<note><tt>constexpr</tt> since C++14 only!</note>
</synopsis>

<synopsis>
<prototype>bool contains(char ch) const</prototype>
<p>Checks whether the set contains <tt>ch</tt>.</p>
</synopsis>

<synopsis>
<prototype>constexpr void add(char ch)</prototype>
<p>Adds <tt>ch</tt> to the set.</p>
<postcondition><tt>contains(ch) == true</tt></postcondition>
<note><tt>constexpr</tt> since C++14 only!</note>
</synopsis>

<synopsis>
<prototype>constexpr void remove(char ch)</prototype>
<p>Removes <tt>ch</tt> from the set.</p>
<postcondition><tt>contains(ch) == false</tt></postcondition>
<note><tt>constexpr</tt> since C++14 only!</note>
</synopsis>

<synopsis>
<prototype>template&lt;class Iter> constexpr void add(Iter begin, Iter end)</prototype>
<prototype>constexpr void add(std::initializer_list&lt;char> set) <badge>C++11</badge></prototype>
<p>Calls <tt>add(ch)</tt> for each value in the range.</p>
<note><tt>constexpr</tt> since C++14 only!</note>
</synopsis>

<synopsis>
<prototype>constexpr void add(const char *c_str)</prototype>
<p>Calls <tt>add(ch)</tt> for each character in the C-string excluding
NULL-terminator.</p>
<note><tt>constexpr</tt> since C++14 only!</note>
</synopsis>

<synopsis>
<prototype>template&lt;class Iter> void assign(Iter begin, Iter end)</prototype>
<prototype>void assign(const char *c_str)</prototype>
<prototype>void assign(std::initializer_list&lt;char> set) <badge>C++11</badge></prototype>
<p>Calls <tt>clear()</tt> then <tt>add()</tt> with the specified parameters.
</p>
</synopsis>

<synopsis>
<prototype>void clear()</prototype>
<p>Removes all elements from the set.</p>
<postcondition><tt>contains(char(ch)) == false</tt> for any char
</postcondition>
</synopsis>

</section>

</chapter>

</chapter>
